/**
 * 
 */
package com.jolestar.yayaweibotong.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author jolestar@gmail.com
 *
 */
public class LogoutAction extends AbstractAction {

	public LogoutAction() {
		super("logout");
	}

	/* (non-Javadoc)
	 * @see com.jolestar.yayaweibotong.controller.AbstractAction#doAction(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected String doAction(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		String logoutUrl = (String) session.getAttribute("logout_url");
		session.invalidate();
		if(logoutUrl == null){
			return "redirect:/index";
		}else{
			return "redirect:"+logoutUrl;
		}
	}

	public String getPath() {
		return "/"+this.getName();
	}

}
